<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>js对象json</title>
</head>
<body>

</body>
<script>
    var user = {
        name: '张三',
        age: 18,
        sex: '男',
        hobby: ['吃饭', '睡觉', '打豆豆'],
        address: {
            province: '北京',
            city: '北京',
            street: '东四'
        },
        sing: function (){
            console.log('正在唱歌...');
        }
    };
    console.log(user.name)
    user.sing()

    var userStr = '{"name":"tom","age":"18","addr":["北京","上海","西安"]}';
    console.log(userStr.name);

    var userObj = JSON.parse(userStr);
    console.log(userObj.name);

    console.log(JSON.stringify(userObj));

</script>
</html>